
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="https://res.szzsi.cn/plugins/hplus/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="https://res.szzsi.cn/plugins/hplus/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="https://res.szzsi.cn/plugins/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="https://res.szzsi.cn/plugins/hplus/css/animate.css" rel="stylesheet">
    <link href="https://res.szzsi.cn/plugins/hplus/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="https://res.szzsi.cn/plugins/hplus/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="https://res.szzsi.cn/css/common.css" rel="stylesheet" type="text/css" />
</head>

<body class="white-bg">
<div class="path">
    会员管理 &raquo; 会员列表
</div>
<div class="wrapper wrapper-content">
    <input type="hidden" name="memberLevel" id="memberLevel" value="1">
    <div class="row">
        <div class="col-sm-12" >
            <div class="alert alert-warning alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                1.在"更新上级"时，切勿把下级调整成<b>同一条线中其上级的上级</b>.<br>
                2.在搜索框输入用户名,编码,推荐人昵称,推荐人编码等,即可检索对应的信息.
            </div>
            <div class="btn-group">
                <button class="member btn btn-primary" type="button" data="1">正式会员</button>
                <button class="member btn btn-white" type="button" data="2">准会员</button>
            </div>
            <%if( strutil.contain (actionIds,"0da7b2e58676453180d65c05719bb74c") || (b_shoprank!)=='super'){%>
            <div id="toolbar">
                <div class="form-inline" role="form">
                    <button type="button" class="btn btn-warning" onclick="exportMember()">导出</button>
                </div>
            </div>
            <%}%>
            <table id="cpTableEvents" data-toggle="table" data-mobile-responsive="true">
                <thead>
                <tr>
                    <th data-field="number" data-formatter="numberFormatter">序号</th>
                    <th data-field="username">用户名</th>
                    <th data-field="realname">真实姓名</th>
                    <th data-field="code">编码</th>
                    <th data-field="sex" data-formatter="sexFormatter">性别</th>
                    <th data-field="memberRankname">会员等级</th>
                    <th data-field="phone">联系方式</th>
                    <th data-field="topUsername">推荐人昵称</th>
                    <th data-field="topRealname">推荐人姓名</th>
                    <th data-field="topCode">推荐人编码</th>
                    <th data-field="createDate">注册日期</th>
                    <th data-field="isAccountLocked" data-formatter="stateFormatter">状态</th>
                    <th data-formatter="headFormatter">操作</th>
                </tr>
                </thead>
            </table>

        </div>
    </div>
</div>
<script src="https://res.szzsi.cn/plugins/hplus/js/plugins/toastr/toastr.min.js"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/jquery.min.js?v=2.1.4"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/content.js?v=1.0.0"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/plugins/layer/layer.min.js"></script>
<script src="https://res.szzsi.cn/plugins/hplus/js/plugins/toastr/toastr.min.js"></script>
<div class="modal inmodal fade" id="addPoint" tabindex="-1" role="dialog"  aria-hidden="true">
    <input type="hidden" id="memberId_p" value=""/>
    <div class="modal-dialog modal-lg" style="width: 300px;">
        <div class="modal-content" style="width: 300px;">
            <div class="modal-header" style="height: 0px">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title" style="font-size: 1.4rem">积分充值</h5>
            </div>
            <div class="modal-body" style="text-align: center;">
                <input name="point" placeholder="请输入充值积分" value="" onkeyup="value=value.replace(/[^\d]/g,'')" onblur="this.value=this.value.replace(/[^\d]/g,'')" style="height: 35px;">
            </div>

            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="sureAddPoint">确认充值</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal fade" id="addMoney" tabindex="-1" role="dialog"  aria-hidden="true">
    <input type="hidden" id="memberId_d" value=""/>
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header" style="height: 0px">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title" style="font-size: 1.4rem">预存款充值</h5>
            </div>
            <div class="modal-body" style="text-align: center;">
                <input name="deposit" placeholder="请输入充值金额" value="" onkeyup="value=value.replace(/[^\d.]/g,'')" onblur="this.value=this.value.replace(/[^\d.]/g,'')" style="height: 35px;">
            </div>
            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="sureAddMoney">确认充值</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal fade" id="changeParent" tabindex="-1" role="dialog"  aria-hidden="true">
    <input type="hidden" id="memberId_cp" value=""/>
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header" style="height: 0px">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h5 class="modal-title" style="font-size: 1.4rem">修改直接上级</h5>
            </div>
            <div class="modal-body" style="text-align: center;">
                <input name="parentcode" placeholder="请输入上级会员编码" value="" onkeyup="value=value.replace(/[^\d.]/g,'')" onblur="this.value=this.value.replace(/[^\d.]/g,'')" style="height: 35px;">
                <div id="msg" style="color: #ff0000"></div>
            </div>
            <div class="modal-footer" style="text-align: center">
                <button type="button" class="btn btn-primary" id="sureChangeParent">确认修改</button>
                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<script>
    //会员导出
    function exportMember(){
        var memberLevel=$("#memberLevel").val();
        window.location.href='${base}/shop/businessmember/exportMember?memberLevel='+memberLevel+'';
    }
    function sexFormatter(value) {
        if(value){
            if(value == 1)
                return '男';
            if(value == 2)
                return '女';
            if(value == 0 || value == null)
                return '未知';
        }else{
            return '未知';
        }
    }

    function a(id,name) {
        parent.layer.open({
            type: 2,
            title: name+'的分销关系',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '98%'],
            content: '${base}/shop/businessmember/fxrelation?id='+id //iframe的url
        });
    }

    function closep(id,type){
        var msg = '';
        if(type == 1){
            msg = '确定要锁定该用户吗？';
        }else{
            msg = '确定要解锁该用户吗？'
        }
        parent.layer.confirm(msg, {
            shade: [0.3,'#fff'],//0.1透明度的白色背景
            btn: ['是','否']
        }, function(){
            $.post('${base}/shop/businessmember/close',{"id":id},function (data) {
                if(data.success){
                    parent.layer.msg('设定成功');
                }
            });
        });

    }
    function resetMemberPassword(id){

        parent.layer.confirm('确定要重置该用户密码吗？', {
            btn: ['是','否']
        }, function(){
            $.post('${base}/shop/businessmember/resetMemberPassword',{"id":id},function (data) {
                if(data.success){
                    parent.layer.msg('设置成功');
                }
            });
        }, function(){

        });

    }

    function getParentUsername(id) {

        layer.open({
            type: 2,
            title: '父推荐关系',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '90%'],
            content: '/html/allParent.jsp?id='+id //iframe的url
        })

//        $.post('${base}/html/getUserParent.jsp',{"pid":id},function (data) {
//            toastr.success(data, '上级信息')
//        });
    }

    function getUserBackMoney(id) {

        layer.open({
            type: 2,
            title: '返佣列表',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '70%'],
            content: '/html/getUserBackMoney.jsp?id='+id //iframe的url
        })
    }

    //预存款管理
    function addMoney(id){
        $("#memberId_d").val(id);
    }
    $("#sureAddMoney").click(function () {
        var memberId=$("#memberId_d").val();
        var deposit=$("input[name='deposit']").val();
        if(!deposit){
            layer.msg("充值金额不能为空!");
            return;
        }
        layer.confirm('您确定要给该用户充值吗? 充值后将不可撤销!', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                url: "${base}/shop/businessmember/addmoney",
                type: 'GET',
                data:{
                    "memberId":memberId,
                    "deposit":deposit
                },
                success: function(data){
                    if(data.code == 1){
                        //注册错误
                        layer.msg(data.desc);
                    }else if (data.code == 0){
                        layer.msg('充值成功!');
                        window.location.reload();

                    }
                }});
        });

    });

    //积分管理
    function addPoint(id){
        $("#memberId_p").val(id);
    }
    $("#sureAddPoint").click(function () {
        var memberId=$("#memberId_p").val();
        var point=$("input[name='point']").val();
        if(!point){
            layer.msg("充值积分不能为空!");
            return;
        }

        layer.confirm('您确定要给该用户充值吗? 充值后将不可撤销!', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                url: "${base}/shop/businessmember/addpoint",
                type: 'GET',
                data:{
                    "memberId":memberId,
                    "point":point
                },
                success: function(data){
                    if(data.code == 1){
                        //注册错误
                        layer.msg(data.desc);
                    }else if (data.code == 0){
                        layer.msg('充值成功!');
                        window.location.reload();

                    }
                }});
        });

    });

    //上级管理
    function changeParent(id){
        $("#memberId_cp").val(id);
    }
    $("#sureChangeParent").click(function () {
        var memberId=$("#memberId_cp").val();
        var parentcode=$("input[name='parentcode']").val();
        if(!parentcode){
            layer.msg("上级code不能为空!");
            return;
        }
        var con=confirm("您确定修改吗? 成功后不可撤销!");
        if(!con){
            return;
        }
        $.post("${base}/shop/businessmember/changeParent",{"id":memberId,"pcode":parentcode},function (data) {
            if(data.code == 1){
                toastr.success(data.desc, '提示')
            }else if (data.code == 0){
                toastr.success('修改成功', '提示')
                $('#msg').html(data.desc);
            }
        });
    });



    function headFormatter(value, row, index){
        var html ='';
        <%if( strutil.contain (actionIds,"3fa6e23330de46eaa43db14c7d0b157d") || (b_shoprank!)=='super'){%>
            html = '<a href="javascript:void(0)" onclick="a(\''+row.id+'\',\''+row.username+'\');" ><i class="fa fa-angle-double-down" data-toggle="tooltip" data-placement="top" title="下级推荐树"></i></a>';
        <%}%>
        <%if( strutil.contain (actionIds,"799e4c0cafc644d599b711df28ce0ff1") || (b_shoprank!)=='super'){%>
            html += '<a href="javascript:void(0)" onclick="getParentUsername(\''+row.id+'\');" ><span style="margin-left:10px;"><i class="fa fa-angle-double-up" data-toggle="tooltip" data-placement="top" title="上级推荐关系"></i></span></a>';
        <%}%>
        <%if( strutil.contain (actionIds,"492547e8a7534a6ebcff585d60c9fd02") || (b_shoprank!)=='super'){%>
            html += '<a href="javascript:void(0)" onclick="getUserBackMoney(\''+row.id+'\');" ><span style="margin-left:10px;"><i class="fa fa-spinner" data-toggle="tooltip" data-placement="top" title="分销金额列表"></i></span></a>';
        <%}%>
        <%if( strutil.contain (actionIds,"109270ceedc7431d96a0e2c2b769e8e2") || (b_shoprank!)=='super'){%>
            html += '<a href="javascript:void(0)" onclick="changeParent(\''+row.id+'\');" ><span style="margin-left:10px;" data-toggle="modal" data-target="#changeParent"><i class="fa fa-level-up" data-toggle="tooltip" data-placement="top" title="更新该用户直接上级"></i></span></a>';
        <%}%>
        <%if( strutil.contain (actionIds,"b4be3c0c44084066917fd41d49dbe878") || (b_shoprank!)=='super'){%>
            html += '<a href="javascript:void(0)" onclick="addMoney(\''+row.id+'\');" ><span style="margin-left:10px;" data-toggle="modal" data-target="#addMoney"><i class="fa fa-cny" data-toggle="tooltip" data-placement="top" title="预存款充值"></i></span></a>';
        <%}%>
        <%if( strutil.contain (actionIds,"4a67fa86548d424ab4953d3ad14a35d5") || (b_shoprank!)=='super'){%>
        html += '<a href="javascript:void(0)" onclick="addPoint(\''+row.id+'\');" ><span style="margin-left:10px;" data-toggle="modal" data-target="#addPoint"><i class="fa fa-btc" data-toggle="tooltip" data-placement="top" title="积分充值"></i></span></a>';
        <%}%>

        <%if( strutil.contain (actionIds,"495d10e6a04842b2bbd429916af29108") || (b_shoprank!)=='super'){%>
        html += '<a href="javascript:void(0)" onclick="resetMemberPassword(\''+row.id+'\');" ><span style="margin-left:10px;"><i class="fa fa-hand-paper-o" data-toggle="tooltip" data-placement="top" title="重置用户密码"></i></span></a>';
        <%}%>
            return html;
    }

    function numberFormatter(value, row, index){
        return index+1;
    }

    function stateFormatter(value){
        if(value){
            return "锁定";
        }else{
            return "正常";
        }
    }

    (function() {
        toastr.options = {
            "positionClass" : "toast-top-center"
        };
        $(".wrapper").tooltip({selector:"[data-toggle=tooltip]",container:"body"});

        $('.member').on('click',function (e) {
            $('.member').removeClass('btn-primary').addClass('btn-white');
            $(this).removeClass('btn-white').addClass('btn-primary');

            $('#cpTableEvents').bootstrapTable("refresh",{query: {memberLevel: $(this).attr('data'),profitDate:$("#start").val()}});
            $("#memberLevel").attr("value",$(this).attr('data'))
        });
        $('#cpTableEvents').bootstrapTable({
            url: "${base}/shop/businessmember/ajaxlist",
            search: true,
            pagination: true,
            showRefresh: true,
            showToggle: true,
            showColumns: true,
            iconSize: 'outline',
            toolbar: '#toolbar',
            icons: {
                refresh: 'glyphicon-repeat',
                toggle: 'glyphicon-list-alt',
                columns: 'glyphicon-list'
            },
        });

        $('#eventsToolbar').on('click',function (e) {
            location.href = 'export';
        })
    })();


</script>
</body>

</html>